package com.ideyatech.allowancereceipts.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;



import com.ideyatech.allowancereceipts.entity.Receipt;

public class ReceiptValidator implements Validator {

	@SuppressWarnings("unchecked")
	public boolean supports(Class clazz) {
		return Receipt.class.isAssignableFrom(clazz);
	}

	public void validate(Object clazz, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "grossPurchase", "error.required", new Object[]{"Municipality"});
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dateOfPurchase", "error.required", new Object[]{"Municipality"});
	}

}
